package chapter6;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;

/**
 * @author yuh
 * @date 2018/4/26 11:09
 * @description
 */
public class Combine2 {

    static List<Object[]> allAlist = new ArrayList<>();

    static void generateCombination(int n, int k, int start, LinkedList<Integer> tmp) {
        if (tmp.size() == k) {
            allAlist.add(tmp.toArray());
            return;
        }
        for (int i = start; i <= n; i++) {
            tmp.addLast(i);
            generateCombination(n, k, start + 1, tmp);
            tmp.removeLast();
        }
    }

    public static void main(String[] args) {
        generateCombination(3, 2, 1, new LinkedList<>());
        for (Object[] objects : allAlist) {
            System.out.println(Arrays.toString(objects));
        }
    }
}
